package com.sinosoft.hydra.um.utils;

import cn.com.sinux.spring.commons.SystemConfig;
import cn.com.sinux.spring.utils.FileUtils;

import java.io.File;
import java.io.IOException;

/**
 * Created by Administrator on 2016/6/20.
 */
public class BakUtils {

    public static final String fileDirectory = "/upload";
    public static final String parseDirectory = "/parse";
    public static final String fileBak = "/bak";

    public static void fileBackup(String path) throws IOException {
        File file = new File(SystemConfig.getProperty("trunk.root.path") + fileDirectory);
        File file2 = new File(path);
        FileUtils.copyDirectoryToDirectory(file, file2);

//        file = new File(SystemConfig.getProperty("trunk.root.path") + parseDirectory);
//        file2 = new File(path);
//        FileUtils.copyDirectoryToDirectory(file, file2);
    }

    public static void fileRecover(String path) throws IOException {
        File file = new File(SystemConfig.getProperty("trunk.root.path") + fileDirectory);
        File file2 = new File(path + fileDirectory);
        FileUtils.deleteDirectory(file);
        FileUtils.copyDirectory(file2, file);

//        file = new File(SystemConfig.getProperty("trunk.root.path") + parseDirectory);
//        file2 = new File(path + parseDirectory);
//        FileUtils.deleteDirectory(file);
//        FileUtils.copyDirectory(file2, file);
    }
}
